package day04;

import java.util.Scanner;

public class WhileDemo {
    public static void main(String[] args) {
        int flag =0;
        while(flag<5){
            System.out.println("行动是成功的阶梯");
            flag++;
        }
        System.out.println("执行完毕");

        int i = 0;
        while(i<9){
            System.out.println("1*"+(i+1)+"="+(1*(i+1)));
            i++;
        }
        System.out.println("执行完毕");

        /**
         * 猜数while/do...while
         */
        /*Scanner input = new Scanner(System.in);
        int num =(int) (Math.random()*1000+1);
        System.out.println(num);
        System.out.println("请输入：");
        int guess = input.nextInt();
        while (guess!=num){
            if(guess>num){
                System.out.println("猜大了");
            }else {
                System.out.println("猜小了");
            }
            System.out.println("继续猜");
            guess = input.nextInt();
        }
        System.out.println("恭喜猜对了");*/

        Scanner input = new Scanner(System.in);
        int num = (int)(Math.random()*1000+1);
        System.out.println(num);
        int guess;
        do{
            System.out.println("请输入：");
            guess = input.nextInt();
            if(guess>num){
                System.out.println("猜大了");

            }else if(guess<num){
                System.out.println("猜小了");

            }else{
                System.out.println("恭喜猜对了");
            }
        }while(guess!=num);

    }
}
